home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bldproj
/
bp.c
next >
Wrap
Text File
|
1988-01-06
|
2KB
|
113 lines
#include <stdio.h>
#include <stdlib.h>
#include <dir.h> /* findfirst/next & struct ffblk */
/*****************************************************************
** build turboc project file from files in arg list
** buildproject mine.prj misc.c this.c that.c etc.c
**
** 1/6/87 -Ejm
**
******************************************************************/
#define TRUE 1
#define FALSE 0
main(argc,argv)
int argc;
char *argv[];
{
FILE *project;
int n;
char Buf[80+1];
struct ffblk fdir;
if(argc<2)
{
printf("Usage %s FILE.PRJ [name.c] [name.c] etc...\n",argv[0]);
printf("Create TURBOC Project File From C sources 1/6/87 -Ejm\n");
exit(1);
}
if(argc<3)
{
argv[argc] = "*.c";
argc++;
}
if( (project=fopen(argv[1],"w+t")) ==NULL)
{
sprintf(Buf,"%s Cant Open File %s",argv[0],argv[1]);
perror(Buf);
exit(1);
}
for(n=2; n<argc; n++)
{
if( findfirst(argv[n],&fdir,0) == 0 )
{
do
{
build(project,fdir.ff_name);
}while( findnext(&fdir) == 0 );
}
}
fcloseall();
exit(0);
}
build(fo,s)
FILE *fo;
char *s;
{
FILE *fi;
char line[512+1];
char delim, *p, name[80+1];
int n;
int iflag = FALSE;
fi = fopen(s,"rt");
if(fi==NULL)
{
printf("File %s Skipped ...");
perror("");
return;
}
fprintf(fo,"%s",s);
printf("Scanning File %s For #include...",s);
while( feof(fi) == FALSE )
{
fgets(line,512,fi);
n = sscanf(line,"#include %c%s",&delim,name);
if(n==2 && delim!='<') /* ignore files in <stdlib.h> */
{
p = strpbrk(name,"\">");
if(p!=NULL)
*p=NULL; /*remove closing bracket or quote */
if(iflag==FALSE)
{
iflag=TRUE;
fprintf(fo," (");
}
else
fprintf(fo," ");
fprintf(fo,"%s",name);
}
}
if(iflag==TRUE)
fprintf(fo,")");
fprintf(fo,"\n");
printf("\n");
fclose(fi);
}